package cn.nextProject.entity;

import lombok.Data;

@Data
public class Result<T> {

    private Integer code;

    private String msg;

    private Long total;

    private T data;

    private String token;

    public Result<?> success(String msg, T data) {
        this.code = 200;
        this.msg = msg;
        this.data = data;
        return this;
    }

    public Result<?> successLogin(String msg,T data,String token) {
        this.code = 200;
        this.msg = msg;
        this.data = data;
        this.token = token;
        return this;
    }

    public Result<?> success(String msg, T data, Long total) {
        this.code = 200;
        this.msg = msg;
        this.data = data;
        this.total = total;
        return this;
    }

    public Result<?> fail(String msg) {
        this.code = 500;
        this.msg = msg;
        return this;
    }

}
